// Using cv::FileStorage to read a .yml file
#include <iostream>
#include <opencv2/opencv.hpp>

int main(int argc, char** argv) {
    cv::FileStorage fs("test.yml", cv::FileStorage::READ);

    int frameCount = (int)fs["frameCount"];
    
    std::string date;
    fs["calibrationDate"] >> date;

    cv::Mat cameraMatrix, distCoeffs;
    fs["cameraMatrix"] >> cameraMatrix;
    fs["distCoeffs"] >> distCoeffs;

    std::cout   << "frameCount: " << frameCount << std::endl
                << "calibration date: " << date << std::endl
                << "camera matrix:"     << cameraMatrix << std::endl
                << "distortion coeffs:" << distCoeffs << std::endl;

    cv::FileNode features = fs["features"];
    cv::FileNodeIterator it = features.begin(), it_end = features.end();
    int idx = 0;
    std::vector<uchar> lbpval;
    for(; it != it_end; ++it, idx++) {
        std::cout << "feature #" << idx << ": ";
        std::cout << "x=" << (int)(*it)["x"] << ", y=" << (int)(*it)["y"] << ", lbp:(";
        (*it)["lbp"] >> lbpval;
        for(int i = 0; i < (int)lbpval.size(); i++) {
            std::cout << " " << (int)lbpval[i];
        }
        std::cout << ")" << std::endl;
    }
    fs.release();

    return 0;
}